package com.smartparking.repository;

import com.smartparking.entity.Reservation;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

/**
 * @author ganru
 * @date 2025/11/3 18:58
 */
@Repository
public interface ReservationRepository extends JpaRepository<Reservation, Integer> {
    // 根据用户ID查找预约记录
    List<Reservation> findByUserUserId(Integer userId);

    // 查找预约状态为"已预约"且在某时间段内的预约
    List<Reservation> findByStatusAndStartTimeBeforeAndEndTimeAfter(String status, Date startTime, Date endTime);

    // 查找某车位的所有预约
    List<Reservation> findByParkingSpaceSpaceId(Integer spaceId);
}